Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

93
Views
ThreeJS | Loading OBJ Data merges meshes

in my ThreeJS application I load a .OBJ file from my local server. I now want for example to give every sub-mesh (sub-component) a different color.

Doing the following, ThreeJS is always coloring more than one meshes:

var counter = 0;
object.traverse(function (child) {

    if (child instanceof THREE.Mesh) {
        //Also tested with if(counter == 300) or if (child.name == '625')...
        if(child.id == 635){
            var randomColor = '#' + (Math.random().toString(16)+'00000').slice(2,8)
            child.material.color.set(randomColor);
        }
        counter++;
    }
});

The result is:

enter image description here

However in a 3D model viewer of your choice (I tested FreeCAD, Blender, Autodesk and Creo) every component seems to be single as it should be...:

enter image description here

How does this happen? Or is there maybe an export option I did not see? Full code: https://www.toptal.com/developers/hastebin/fosugibuni.php (Not very spectacular)...

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!